package com.huitong.oss.config;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import com.huitong.oss.properties.OSSCustomProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 阿里云OSS配置
 *
 * @author fromdrowning
 * @date 2024/5/19 下午7:31
 */
@Configuration
public class OSSConfiguration {

    /**
     * 阿里云OSS客户端配置
     *
     * @param ossCustomProperties 阿里云OSS自定义配置
     * @return 阿里云OSS客户端
     */
    @Bean
    public OSS ossCustomizer(OSSCustomProperties ossCustomProperties) {
        return new OSSClientBuilder()
            .build(ossCustomProperties.getEndpoint(), ossCustomProperties.getAccessKeyId(), ossCustomProperties.getAccessKeySecret());
    }
}
